package de.metalcon.gwt.client.interactions;

import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.PopupPanel;

import de.metalcon.gwt.client.mainDesign.MainContent;

public abstract class AInteraction extends PopupPanel implements
		CloseHandler<PopupPanel> {
	public AInteraction() {
		super(false); // no autohide when clicked outside
	}

	public AInteraction(boolean autoHide) {
		super(autoHide);
		addCloseHandler(this);
	}

	@Override
	public void onClose(CloseEvent<PopupPanel> event) {
		MainContent.CloseInteraction(this);
	}

	public abstract String getHistoryActionToken();

	protected abstract void generateContent();

	public static String generateHistoryToken(String suffix) {
		if(!History.getToken().contains("$" + suffix)){
			return History.getToken() + "$" + suffix;
		}
		return History.getToken(); 
	}
}
